package P088_enumFactory;

import org.junit.Test;

/**
 * @Description : 枚举实现工厂
 **/
public class EnumFactory {

    @Test
    public void test() {
        CarFactory.createCar(BuickCar.class);
    }

    @Test
    public void test1() {
      Car car= CarFacory1.BuickCar.create();
    }

    enum CarFacory1{
        FordCar,BuickCar;
        public Car create(){
            switch(this){
                case FordCar: return new FordCar();
                case BuickCar: return new BuickCar();
                default: throw new AssertionError("error");
            }
        }
    }
}
